package com.help10000.rms.ui.activitys

import android.os.Bundle

import androidx.recyclerview.widget.LinearLayoutManager
import com.amir.common.beans.MyOrderEntity
import com.amir.common.beans.OrderItem
import com.amir.common.weight.SpaceItemDecoration
import com.help10000.rms.R
import com.help10000.rms.mvp.presenter.OverTimeOrderPresenter
import com.help10000.rms.mvp.view.OverTimeOrderView
import com.help10000.rms.ui.adapter.OverTimeOrderAdapter
import com.help10000.rms.ui.base.BaseActivity
import kotlinx.android.synthetic.main.activity_over_time.*

/**
 * 超时订单
 */
class TimeOutOrderActivity : BaseActivity<OverTimeOrderPresenter, OverTimeOrderView>(),
    OverTimeOrderView {
    var PageNo = 1
    var overTimeOrderAdapter: OverTimeOrderAdapter? = null
    var list = mutableListOf<OrderItem>()
    override fun getlayoutId(): Int {
        return R.layout.activity_over_time
    }

    override fun initView() {
        initRefreshLayout(refresh)
    }

  override fun initData(savedInstanceState: Bundle?){

        downOnRefresh()
        val linearLayoutManager = LinearLayoutManager(mContext)
        rv_list.layoutManager = linearLayoutManager

         overTimeOrderAdapter =
            OverTimeOrderAdapter(mContext, list, R.layout.item_overtimeorder_layout)
        rv_list.adapter = overTimeOrderAdapter
        rv_list.addItemDecoration(SpaceItemDecoration(0, 10))
    }

    override fun downOnRefresh() {
       PageNo = 1
        this.list.clear()
        mPresenter.overTimeOrderList(PageNo)
    }

    override fun loadMore() {
        PageNo++
    }
    override fun createPresenter(): OverTimeOrderPresenter {
        return OverTimeOrderPresenter(this)
    }

    override fun orderSuccess(t: MyOrderEntity) {
        this.list.addAll(t.data.OrderList)
        overTimeOrderAdapter?.notifyDataSetChanged()
    }
}